<?php
/**
 * Booking Controller for RoomBooking Component
 * 
 * @version 1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license		GNU/GPL
 */
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport('joomla.application.component.controller');
 
class RoomBookingController extends JController
{

	function __construct()
	{
		parent::__construct();
	}
    /**
     * Method to display the view
     *
     * @access    public
     */
    function display()
    {	
    	if( JRequest::getVar('view')=='roombooking'){
            $modelBuildings =& $this->getModel('buildings');
            $modelRooms =& $this->getModel('rooms');
            $view = $this->getView('roombooking','html');
            $view->setModel($modelBuildings);
            $view->setModel($modelRooms);
            $layout = JRequest::getVar('layout');
            if ($layout=='dyn_select'){
            	$modelBuildings =& $this->getModel('buildings');
                $document = &JFactory::getDocument();
                $doc = &JDocument::getInstance('raw');
                $document = $doc;
            }
			$modelOrganizations = &$this->getModel('organizations');
            $view->setModel($modelOrganizations);
    	
    	} else if (JRequest::getVar('view')=='bookings'){
    		$view = $this->getView('bookings','html');
            $modelRoom =& $this->getModel('room');
            $view->setModel($modelRoom);
            $modelBuilding =& $this->getModel('building');
            $view->setModel($modelBuilding);
            $modelBookings =& $this->getModel('bookings');
            $view->setModel($modelBookings);
         }else if(JRequest::getVar('view')=='bookinglist'){
             $view = $this->getView('bookinglist','html');
            $modelBookings =& $this->getModel('bookings');
            $view->setModel($modelBookings);
         }
        
        parent::display();
    }
    
 
 
}
